home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / log / checkPointTrans.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  3.9 KB  |  174 lines

  1. /*
  2.  *   $RCSfile: checkPointTrans.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:55:50 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37.  
  38. #include "sysdefs.h"
  39. #include "ess.h"
  40. #include "checking.h"
  41. #include "trace.h"
  42. #include "error.h"
  43. #include "list.h"
  44. #include "pool.h"
  45. #include "tid.h"
  46. #include "io.h"
  47. #include "lock.h"
  48. #include "object.h"
  49. #include "msgdefs.h"
  50. #include "thread.h"
  51. #include "semaphore.h"
  52. #include "latch.h"
  53. #include "link.h"
  54. #include "lsn.h"
  55. #include "bf.h"
  56. #include "volume.h"
  57. #include "openlog.h"
  58. #include "trans.h"
  59. #include "logrecs.h"
  60. #include "threadstate.h"
  61. #include "util_funcs.h"
  62. #include "log_intfuncs.h"
  63. #include "log_extfuncs.h"
  64. #include "thread_globals.h"
  65. #include "log_globals.h"
  66. #include "trans_globals.h"
  67.  
  68.  
  69.  int
  70. checkPointTrans (
  71.  
  72.     register CHECKTRANS    *transList 
  73. )
  74. {
  75.  
  76.     register TRANSREC    *transRec;
  77.     register int        transCount;
  78.  
  79.  
  80.     TRACE(TR_LOG, TR_LEVEL_1);
  81.  
  82.     /*
  83.      *    initialize the count and get the pointer to the first transaction
  84.      */
  85.     transCount = 0;
  86.     transRec = (TRANSREC *) FIRST_LIST_ELEMENT( &(ActiveTransList) );
  87.  
  88.     /*
  89.      *    run down the list of active transactions
  90.      */
  91.     while (transRec != NULL)    {
  92.  
  93.         /*
  94.          *    check the transrec magic number
  95.          */
  96.         CHECK_TRANSREC_MAGIC(transRec);
  97.  
  98.         /*
  99.          *    record the information from the transaction
  100.          *  if the transaction is one that will need recovery
  101.          */
  102.         switch (transRec->transState)    {
  103.  
  104.             case T_ACTIVE:
  105.             case T_LATENT:
  106.             case T_QUIESCE:
  107.             case T_ABORT:
  108.  
  109.                 transList->state = T_ACTIVE;
  110.                 break;
  111.  
  112.             case T_COMMIT:
  113.                 /*
  114.                 * commented out for minor efficiency:
  115.                 * do not include committed transactions in the checkpoint 
  116.                 transList->state = T_COMMIT;
  117.                 break;
  118.                 */
  119.  
  120.                 /*
  121.                  *    for distr trans 
  122.                  */
  123.                 if (transRec->numServers == 0) {
  124.  
  125.                     goto nextTransRec; /* continue */
  126.                 }
  127.                 else {
  128.                     transList->state = T_COMMIT;
  129.                 }
  130.                 break;
  131.  
  132.             case T_PREPARED:
  133.  
  134.                 transList->state = T_PREPARED;
  135.                 break;
  136.  
  137.             case T_END:
  138.                 
  139.                 transList->state = T_END;
  140.                 break;
  141.                 
  142.         }
  143.         transList->firstLSN    = transRec->firstLSN;
  144.         transList->lastLSN    = transRec->lastLSN;
  145.         transList->tid        = transRec->tid;
  146.         transList->nextUndoLSN = transRec->nextUndoLSN;
  147.         /*
  148.          *    for distr trans
  149.          */
  150.         transList->numServers = transRec->numServers;
  151.         transList->prepareLSN = transRec->prepareLSN;
  152.  
  153.         TRPRINT(TR_LOG, TR_LEVEL_2, ("tid:%x", GETTID(transRec)));
  154.  
  155.         /*
  156.          *    increment the count of transactions
  157.          */
  158.         transCount++;
  159.  
  160.         /*
  161.          *    go to the next element
  162.          */
  163.         transList++;
  164.  
  165.     nextTransRec:
  166.         transRec = (TRANSREC *) NEXT_LIST_ELEMENT( &(transRec->activeTransList) );
  167.     }
  168.  
  169.     /*
  170.      *    return the count of transactions
  171.      */
  172.     return(transCount);
  173. }
  174.